#ifndef GC_H
#define GC_H

#include "deviser.h"

typedef struct _ext_ref
{
	cell ref;
	struct _ext_ref * next;
} ext_ref;

extern unsigned int num_cons;

extern ext_ref * root_set;

cell alloc_cell(unsigned int num);
unsigned int consp(cell* ref);
unsigned int nullp(cell* ref);
unsigned int numberp(cell* ref);
unsigned int eqp(cell* ref1, cell* ref2);
unsigned int eeqp(cell ref1, cell ref2);
unsigned int eqvp(cell* ref1, cell* ref2);
unsigned int eeqvp(cell ref1, cell ref2);
cell ecdr(cell ref);
cell ecar(cell ref);
cell car(cell* _ref);
cell cdr(cell* _ref);
cell cons(cell _car, cell _cdr);
unsigned short number_to_cint(cell ref);
cell mk_number(unsigned short n);
cell mk_eol();
cell mk_symbol(const char * data, unsigned int len);
unsigned int enullp(cell ref);
unsigned int symbolp(cell* sym);
cell symbol_to_string(cell* sym);
void set_cdr(cell pair, cell new_cdr);
unsigned int stringp(cell* ref);
const char * get_str_val(cell* ref);
unsigned int get_str_len(cell* ref);
cell mk_cfunc(dvs_func f);
dvs_func get_cfunc(cell* val);
unsigned int cfuncp(cell* val);
cell mk_lfunc(cell* env, cell* code);
unsigned int lfuncp(cell* val);
cell get_env(cell* fun);
cell get_code(cell* fun);
cell mk_bool(unsigned int val);
unsigned int boolp(cell* val);
unsigned int falsep(cell* val);
void init_gc();

unsigned int gc_halt();
void gc_resume();

#endif
